import { reactive, ref, toRefs, computed, watch, onMounted, onUnmounted } from 'vue'
import { router, api, $dialog, $error, $success, $confirm, $pop, $local, $session, $cache } from '@/tools'
import { useForm } from '@ant-design-vue/use';
export default function useLogin() {
  const state = reactive({
    loginType: "account",  // phone
    saveAccount:true,   // 自动记住密码
    // 账号登录
    accountLoginErrMsg: "",
  })

  const accountForm = reactive({
    account: '',
    password: "",
  });
  const accountRule = reactive({
    account: [{ required: true, message: '请输入帐户名', },],
    password: [{ required: true, message: '请输入密码', },],
  });
  const { 
    resetFields: accountResetFields,
    validate: accountValidate,
    validateInfos: accountValidateInfos
  } = useForm(accountForm, accountRule);
  const fn = {
    xxx: () => {
    }
  }
  return {
    loginState: state,
    loginFn: fn,
    accountForm,
    accountResetFields,
    accountValidate,
    accountValidateInfos
  }
}